package javaer.starter.idea.util;

import com.intellij.notification.*;
import com.intellij.notification.impl.NotificationGroupEP;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.Messages;
import javaer.starter.JavaerStarter;

import java.util.Collection;

/**
 * @author yangzhen
 * @date 2023/7/24 10:38
 * @since 1.0.0
 */
public class MessageUtils {

    public static void showError(String message) {
        Messages.showErrorDialog(message, JavaerStarter.PROJECT_ID);
    }

    public static void showInfo(String message) {
        Messages.showInfoMessage(message, JavaerStarter.PROJECT_ID);
    }

    public static void notifyError(String message) {
        notify(message, MessageType.ERROR);
    }

    public static void notifyInfo(String message) {
        notify(message, MessageType.INFO);
    }

    public static void notify(String message, MessageType messageType) {
        NotificationGroupManager instance = NotificationGroupManager.getInstance();
        NotificationGroup notificationGroup = instance.getNotificationGroup(JavaerStarter.PROJECT_ID);
        Notification info = notificationGroup.createNotification(JavaerStarter.PROJECT_ID + ": " + message, messageType);
        Notifications.Bus.notify(info);
    }
}
